<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<include file="Public/head" />
<link href="__STATIC__/css/user.css" type="text/css" rel="stylesheet" />
</head>

<body>
<include file="Public/top" />

<div class="page_minheight">
<div class="login_tit">
  <div class="return"><a href="{:U('User/index')}"><i class="icon-fanhui"></i></a></div>
  <span>修改登录密码</span>
</div><!--login_tit-->
<div class="page_in margin">
  <form action="" method="post" onSubmit="return check_form();">
    <div class="ginput_div ginput_div_icon"><i class="icon-shouji1"></i><input class="ginput" type="text" name="old_mobile" id="old_mobile" value="{$user_info['mobile']}" readonly /></div>
    <div class="ginput_div ginput_div_icon"><i class="icon-shouji1"></i><input class="ginput" type="text" name="mobile" id="new_mobile" placeholder="新手机号码" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" /></div>
    <div class="ginput_div ginput_div_icon">
      <div class="fl"><i class="icon-yanzhengma2"></i><input class="ginput" name="code" id="new_code" type="text" placeholder="短信验证码" /></div>
      <div class="fr"><button type="button" class="reg_send" id="count_down1" onClick="sendCode('new_mobile')">获取短信验证码</button></div>
      <div class="clear"></div>
    </div>
    <div class="ginput_div"><button type="submit" class="login_sub">提交</button></div>
  </form>
</div><!--page_in-->
</div><!--page_minheight-->

<script>
	// 表单提交验证
	function check_form()
	{
        var old_mobile = $('#old_mobile').val();		
        var new_mobile = $('#new_mobile').val();
        //原邮箱不为空的情况下 验证格式
        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
            if(!checkMobile(old_mobile)){
                layer.alert('原手机格式错误', {icon: 2});// alert('原手机格式错误');
                return false;
            }
        }
        if(!checkMobile(new_mobile)){
            layer.alert('新手机格式错误', {icon: 2});//alert('新手机格式错误');
            return false;
        }	
		
		if($.trim($('#new_code').val()) == '')	
		{
            layer.alert('验证码不能为空', {icon: 2});//alert('验证码不能为空');
            return false;			
		}
		return true;
	} 
    function sendCode(input_id){
        var input = $('#'+input_id).val();
        var old_mobile = $('#old_mobile').val();
        //原邮箱不为空的情况下 验证格式
//        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
//            if(!checkMobile(old_mobile)){
//                layer.alert('原手机格式错误', {icon: 2});//alert('原手机格式错误');
//                return false;
//            }
//        }
        if(!checkMobile(input)){
            layer.alert('手机号码格式错误', {icon: 2});//alert('手机号码格式错误');
            return false;
        }
        if(input_id == 'old_mobile')
            var url = "/index.php?m=Mobile&c=User&a=send_validate_code&step=1&type=mobile&send="+input;
        if(input_id == 'new_mobile')
//            var url = "/index.php?m=Mobile&c=User&a=send_validate_code&step=2&type=mobile&send="+input;
        var url = "/index.php?m=Home&c=User&a=send_sms_reg_code&mobile="+input;
        //发送验证码
        $.ajax({
            type : "GET",
            url  : url,
            dataType : 'json',
            error: function(request) {
                layer.alert('服务器繁忙, 请联系管理员!', {icon: 2});//alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function(res) {
                if(res.status == 1){
//                    jsInnerTimeout(id);
                    layer.alert(res.msg,{icon: 1});
                    counttime = "{$sms_time_out}"; // 手机短信超时时间
                    countdown('#count_down1',counttime);
                }else{
                    layer.alert(res.msg,{icon: 2});//alert('发送失败');
                }
            }
        });
    }

    //倒计时函数
   function countdown(divid,counttime)
	{
		$(divid).attr("disabled","disabled");
		$(divid).addClass("reg_send_off");
		
		counttime--;
        if(counttime<=-1)
        {
			$(divid).removeAttr("disabled");
			$(divid).removeClass("reg_send_off");
            $(divid).html("获取短信验证码");
            return false;
        }

        $(divid).html(counttime+'秒');

        setTimeout("countdown('"+divid+"',"+counttime+")",1000);
	}

</script>

<include file="Public/footer" />
<script src="__STATIC__/js/global_after.js" type="text/javascript"></script>
</body>
</html>